home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / MPLYIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  9.8 KB  |  408 lines

  1. unit MPlyImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib, MPlayer;
  8.  
  9. type
  10.   TMediaPlayerX = class(TActiveXControl, IMediaPlayerX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TMediaPlayer;
  14.     FEvents: IMediaPlayerXEvents;
  15.     procedure ClickEvent(Sender: TObject; Button: TMPBtnType;
  16.       var DoDefault: Boolean);
  17.     procedure NotifyEvent(Sender: TObject);
  18.   protected
  19.     { Protected declarations }
  20.     procedure InitializeControl; override;
  21.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     function Get_AutoEnable: WordBool; safecall;
  24.     function Get_AutoOpen: WordBool; safecall;
  25.     function Get_AutoRewind: WordBool; safecall;
  26.     function Get_Cursor: Smallint; safecall;
  27.     function Get_DeviceID: Smallint; safecall;
  28.     function Get_DeviceType: TxMPDeviceTypes; safecall;
  29.     function Get_Enabled: WordBool; safecall;
  30.     function Get_EndPos: Integer; safecall;
  31.     function Get_Error: Integer; safecall;
  32.     function Get_ErrorMessage: WideString; safecall;
  33.     function Get_FileName: WideString; safecall;
  34.     function Get_Frames: Integer; safecall;
  35.     function Get_Length: Integer; safecall;
  36.     function Get_Mode: TxMPModes; safecall;
  37.     function Get_Notify: WordBool; safecall;
  38.     function Get_NotifyValue: TxMPNotifyValues; safecall;
  39.     function Get_Position: Integer; safecall;
  40.     function Get_Shareable: WordBool; safecall;
  41.     function Get_Start: Integer; safecall;
  42.     function Get_StartPos: Integer; safecall;
  43.     function Get_TimeFormat: TxMPTimeFormats; safecall;
  44.     function Get_Tracks: Integer; safecall;
  45.     function Get_Visible: WordBool; safecall;
  46.     function Get_Wait: WordBool; safecall;
  47.     procedure AboutBox; safecall;
  48.     procedure Back; safecall;
  49.     procedure Close; safecall;
  50.     procedure Eject; safecall;
  51.     procedure Next; safecall;
  52.     procedure Open; safecall;
  53.     procedure Pause; safecall;
  54.     procedure PauseOnly; safecall;
  55.     procedure Play; safecall;
  56.     procedure Previous; safecall;
  57.     procedure Resume; safecall;
  58.     procedure Rewind; safecall;
  59.     procedure Save; safecall;
  60.     procedure Set_AutoEnable(Value: WordBool); safecall;
  61.     procedure Set_AutoOpen(Value: WordBool); safecall;
  62.     procedure Set_AutoRewind(Value: WordBool); safecall;
  63.     procedure Set_Cursor(Value: Smallint); safecall;
  64.     procedure Set_DeviceType(Value: TxMPDeviceTypes); safecall;
  65.     procedure Set_Enabled(Value: WordBool); safecall;
  66.     procedure Set_EndPos(Value: Integer); safecall;
  67.     procedure Set_FileName(const Value: WideString); safecall;
  68.     procedure Set_Frames(Value: Integer); safecall;
  69.     procedure Set_Notify(Value: WordBool); safecall;
  70.     procedure Set_Position(Value: Integer); safecall;
  71.     procedure Set_Shareable(Value: WordBool); safecall;
  72.     procedure Set_StartPos(Value: Integer); safecall;
  73.     procedure Set_TimeFormat(Value: TxMPTimeFormats); safecall;
  74.     procedure Set_Visible(Value: WordBool); safecall;
  75.     procedure Set_Wait(Value: WordBool); safecall;
  76.     procedure StartRecording; safecall;
  77.     procedure Step; safecall;
  78.     procedure Stop; safecall;
  79.   end;
  80.  
  81. implementation
  82. uses MplyPg;
  83. { TMediaPlayerX }
  84.  
  85. procedure TMediaPlayerX.InitializeControl;
  86. begin
  87.   FDelphiControl := Control as TMediaPlayer;
  88.   FDelphiControl.OnClick := ClickEvent;
  89.   FDelphiControl.OnNotify := NotifyEvent;
  90. end;
  91.  
  92. procedure TMediaPlayerX.EventSinkChanged(const EventSink: IUnknown);
  93. begin
  94.   FEvents := EventSink as IMediaPlayerXEvents;
  95. end;
  96.  
  97. procedure TMediaPlayerX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  98. begin
  99.   { Define property pages here.  Property pages are defined by calling
  100.     DefinePropertyPage with the class id of the page.  For example,
  101.       DefinePropertyPage(Class_MediaPlayerXPage); }
  102. end;
  103.  
  104. function TMediaPlayerX.Get_AutoEnable: WordBool;
  105. begin
  106.   Result := FDelphiControl.AutoEnable;
  107. end;
  108.  
  109. function TMediaPlayerX.Get_AutoOpen: WordBool;
  110. begin
  111.   Result := FDelphiControl.AutoOpen;
  112. end;
  113.  
  114. function TMediaPlayerX.Get_AutoRewind: WordBool;
  115. begin
  116.   Result := FDelphiControl.AutoRewind;
  117. end;
  118.  
  119. function TMediaPlayerX.Get_Cursor: Smallint;
  120. begin
  121.   Result := Smallint(FDelphiControl.Cursor);
  122. end;
  123.  
  124. function TMediaPlayerX.Get_DeviceID: Smallint;
  125. begin
  126.   Result := Smallint(FDelphiControl.DeviceID);
  127. end;
  128.  
  129. function TMediaPlayerX.Get_DeviceType: TxMPDeviceTypes;
  130. begin
  131.   Result := Ord(FDelphiControl.DeviceType);
  132. end;
  133.  
  134. function TMediaPlayerX.Get_Enabled: WordBool;
  135. begin
  136.   Result := FDelphiControl.Enabled;
  137. end;
  138.  
  139. function TMediaPlayerX.Get_EndPos: Integer;
  140. begin
  141.   Result := FDelphiControl.EndPos;
  142. end;
  143.  
  144. function TMediaPlayerX.Get_Error: Integer;
  145. begin
  146.   Result := FDelphiControl.Error;
  147. end;
  148.  
  149. function TMediaPlayerX.Get_ErrorMessage: WideString;
  150. begin
  151.   Result := WideString(FDelphiControl.ErrorMessage);
  152. end;
  153.  
  154. function TMediaPlayerX.Get_FileName: WideString;
  155. begin
  156.   Result := WideString(FDelphiControl.FileName);
  157. end;
  158.  
  159. function TMediaPlayerX.Get_Frames: Integer;
  160. begin
  161.   Result := FDelphiControl.Frames;
  162. end;
  163.  
  164. function TMediaPlayerX.Get_Length: Integer;
  165. begin
  166.   Result := FDelphiControl.Length;
  167. end;
  168.  
  169. function TMediaPlayerX.Get_Mode: TxMPModes;
  170. begin
  171.   Result := Ord(FDelphiControl.Mode);
  172. end;
  173.  
  174. function TMediaPlayerX.Get_Notify: WordBool;
  175. begin
  176.   Result := FDelphiControl.Notify;
  177. end;
  178.  
  179. function TMediaPlayerX.Get_NotifyValue: TxMPNotifyValues;
  180. begin
  181.   Result := Ord(FDelphiControl.NotifyValue);
  182. end;
  183.  
  184. function TMediaPlayerX.Get_Position: Integer;
  185. begin
  186.   Result := FDelphiControl.Position;
  187. end;
  188.  
  189. function TMediaPlayerX.Get_Shareable: WordBool;
  190. begin
  191.   Result := FDelphiControl.Shareable;
  192. end;
  193.  
  194. function TMediaPlayerX.Get_Start: Integer;
  195. begin
  196.   Result := FDelphiControl.Start;
  197. end;
  198.  
  199. function TMediaPlayerX.Get_StartPos: Integer;
  200. begin
  201.   Result := FDelphiControl.StartPos;
  202. end;
  203.  
  204. function TMediaPlayerX.Get_TimeFormat: TxMPTimeFormats;
  205. begin
  206.   Result := Ord(FDelphiControl.TimeFormat);
  207. end;
  208.  
  209. function TMediaPlayerX.Get_Tracks: Integer;
  210. begin
  211.   Result := FDelphiControl.Tracks;
  212. end;
  213.  
  214. function TMediaPlayerX.Get_Visible: WordBool;
  215. begin
  216.   Result := FDelphiControl.Visible;
  217. end;
  218.  
  219. function TMediaPlayerX.Get_Wait: WordBool;
  220. begin
  221.   Result := FDelphiControl.Wait;
  222. end;
  223.  
  224. procedure TMediaPlayerX.AboutBox;
  225. begin
  226.   ShowMediaPlayerXAbout;
  227. end;
  228.  
  229. procedure TMediaPlayerX.Back;
  230. begin
  231.   FDelphiControl.Back;
  232. end;
  233.  
  234. procedure TMediaPlayerX.Close;
  235. begin
  236.   FDelphiControl.Close;
  237. end;
  238.  
  239. procedure TMediaPlayerX.Eject;
  240. begin
  241.   FDelphiControl.Eject;
  242. end;
  243.  
  244. procedure TMediaPlayerX.Next;
  245. begin
  246.   FDelphiControl.Next;
  247. end;
  248.  
  249. procedure TMediaPlayerX.Open;
  250. begin
  251.   FDelphiControl.Open;
  252. end;
  253.  
  254. procedure TMediaPlayerX.Pause;
  255. begin
  256.   FDelphiControl.Pause;
  257. end;
  258.  
  259. procedure TMediaPlayerX.PauseOnly;
  260. begin
  261.   FDelphiControl.PauseOnly;
  262. end;
  263.  
  264. procedure TMediaPlayerX.Play;
  265. begin
  266.   FDelphiControl.Play;
  267. end;
  268.  
  269. procedure TMediaPlayerX.Previous;
  270. begin
  271.   FDelphiControl.Previous;
  272. end;
  273.  
  274. procedure TMediaPlayerX.Resume;
  275. begin
  276.   FDelphiControl.Resume;
  277. end;
  278.  
  279. procedure TMediaPlayerX.Rewind;
  280. begin
  281.   FDelphiControl.Rewind;
  282. end;
  283.  
  284. procedure TMediaPlayerX.Save;
  285. begin
  286.   FDelphiControl.Save;
  287. end;
  288.  
  289. procedure TMediaPlayerX.Set_AutoEnable(Value: WordBool);
  290. begin
  291.   FDelphiControl.AutoEnable := Value;
  292. end;
  293.  
  294. procedure TMediaPlayerX.Set_AutoOpen(Value: WordBool);
  295. begin
  296.   FDelphiControl.AutoOpen := Value;
  297. end;
  298.  
  299. procedure TMediaPlayerX.Set_AutoRewind(Value: WordBool);
  300. begin
  301.   FDelphiControl.AutoRewind := Value;
  302. end;
  303.  
  304. procedure TMediaPlayerX.Set_Cursor(Value: Smallint);
  305. begin
  306.   FDelphiControl.Cursor := TCursor(Value);
  307. end;
  308.  
  309. procedure TMediaPlayerX.Set_DeviceType(Value: TxMPDeviceTypes);
  310. begin
  311.   FDelphiControl.DeviceType := TMPDeviceTypes(Value);
  312. end;
  313.  
  314. procedure TMediaPlayerX.Set_Enabled(Value: WordBool);
  315. begin
  316.   FDelphiControl.Enabled := Value;
  317. end;
  318.  
  319. procedure TMediaPlayerX.Set_EndPos(Value: Integer);
  320. begin
  321.   FDelphiControl.EndPos := Value;
  322. end;
  323.  
  324. procedure TMediaPlayerX.Set_FileName(const Value: WideString);
  325. begin
  326.   FDelphiControl.FileName := String(Value);
  327. end;
  328.  
  329. procedure TMediaPlayerX.Set_Frames(Value: Integer);
  330. begin
  331.   FDelphiControl.Frames := Value;
  332. end;
  333.  
  334. procedure TMediaPlayerX.Set_Notify(Value: WordBool);
  335. begin
  336.   FDelphiControl.Notify := Value;
  337. end;
  338.  
  339. procedure TMediaPlayerX.Set_Position(Value: Integer);
  340. begin
  341.   FDelphiControl.Position := Value;
  342. end;
  343.  
  344. procedure TMediaPlayerX.Set_Shareable(Value: WordBool);
  345. begin
  346.   FDelphiControl.Shareable := Value;
  347. end;
  348.  
  349. procedure TMediaPlayerX.Set_StartPos(Value: Integer);
  350. begin
  351.   FDelphiControl.StartPos := Value;
  352. end;
  353.  
  354. procedure TMediaPlayerX.Set_TimeFormat(Value: TxMPTimeFormats);
  355. begin
  356.   FDelphiControl.TimeFormat := TMPTimeFormats(Value);
  357. end;
  358.  
  359. procedure TMediaPlayerX.Set_Visible(Value: WordBool);
  360. begin
  361.   FDelphiControl.Visible := Value;
  362. end;
  363.  
  364. procedure TMediaPlayerX.Set_Wait(Value: WordBool);
  365. begin
  366.   FDelphiControl.Wait := Value;
  367. end;
  368.  
  369. procedure TMediaPlayerX.StartRecording;
  370. begin
  371.   FDelphiControl.StartRecording;
  372. end;
  373.  
  374. procedure TMediaPlayerX.Step;
  375. begin
  376.   FDelphiControl.Step;
  377. end;
  378.  
  379. procedure TMediaPlayerX.Stop;
  380. begin
  381.   FDelphiControl.Stop;
  382. end;
  383.  
  384. procedure TMediaPlayerX.ClickEvent(Sender: TObject; Button: TMPBtnType;
  385.   var DoDefault: Boolean);
  386. var
  387.   TempDoDefault: WordBool;
  388. begin
  389.   TempDoDefault := WordBool(DoDefault);
  390.   if FEvents <> nil then FEvents.OnClick(TxMPBtnType(Button), TempDoDefault);
  391.   DoDefault := Boolean(TempDoDefault);
  392. end;
  393.  
  394. procedure TMediaPlayerX.NotifyEvent(Sender: TObject);
  395. begin
  396.   if FEvents <> nil then FEvents.OnNotify;
  397. end;
  398.  
  399. initialization
  400.   TActiveXControlFactory.Create(
  401.     ComServer,
  402.     TMediaPlayerX,
  403.     TMediaPlayer,
  404.     Class_MediaPlayerX,
  405.     12,
  406.     '{5A565996-7975-11D0-BE02-00A024D1875C}');
  407. end.
  408.